fix: use TypeAdapter for union dict defaults in type aliases and inline unions#3041
fix: use TypeAdapter for union dict defaults in type aliases and inline unions#3041koxudaxi wants to merge 1 commit into
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe changes enhance default value handling for Pydantic v2 union types. When a field references a type alias or contains an inline union of BaseModels with a dict default value, the code now generates TypeAdapter-based validation to properly validate the default against the entire union, rather than leaving it as a raw dict or validating only against the first union member. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
📚 Docs Preview: https://pr-3041.datamodel-code-generator.pages.dev |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3041 +/- ##
===========================================
- Coverage 100.00% 99.97% -0.03%
===========================================
Files 85 85
Lines 17684 17720 +36
Branches 2068 2078 +10
===========================================
+ Hits 17684 17716 +32
- Partials 0 4 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
4fdbf7e to
738f3e0
Compare
Merging this PR will not alter performance
|
Fixes: #3034
Fixes: #3035
Summary by CodeRabbit
New Features
Tests